package com.order.hit.crossover.platform.common.utils;


import com.order.hit.crossover.platform.common.bean.order.Order;
import com.order.hit.crossover.platform.common.bean.Store_Value;
import com.order.hit.crossover.platform.common.bean.order.OrderType;
import com.order.hit.crossover.platform.common.bean.order.Quotation;

public class CountEachOrderValue
{
    //  计算新模式下每单的价值提升
    public static double countValue(Order order, Quotation quotation, Store_Value storeValue) {

        double value = 0.0;

        double customer_satisfy = 50;
        double profit = 100;
        double sale = 100;
        double sales_volume = 100;

        //  门店A求购(假设报价低于预计价格)
        if(order.getOrderType().toString().equalsIgnoreCase(OrderType.ORDER_BUY.toString())) {
            sale *= quotation.getPrice()/order.getPrice();
            profit *= (order.getPrice() - quotation.getPrice())/order.getPrice();
        }
        //  门店A求售（假设报价高于预计价格）
        else {
            sale *= order.getPrice()/quotation.getPrice();
            profit *= (quotation.getPrice() - order.getPrice())/order.getPrice();
        }

        sales_volume *= 1.0 * quotation.getGoodNumber()/order.getGoodNumber();

        value = storeValue.CalculatedValue(customer_satisfy, profit, sale, sales_volume);

        return value;

    }

}
